package com.yuyang.wifi.views.recyclerview.swipe;

import android.util.Log;

import static android.content.ContentValues.TAG;

/**
 * Created by tik on 17/8/14.
 */

public class RefreshStatus {
	public static final int STATUS_REFRESHING = -3;
	public static final int STATUS_RELEASE_TO_REFRESH = -2;
	public static final int STATUS_SWIPING_TO_REFRESH = -1;
	public static final int STATUS_DEFAULT = 0;
	public static final int STATUS_SWIPING_TO_LOAD_MORE = 1;
	public static final int STATUS_RELEASE_TO_LOAD_MORE = 2;
	public static final int STATUS_LOADING_MORE = 3;
	public static final int STATUS_LOAD_MORE_RETURNING = 4;

	public static boolean isRefreshing(final int status) {
		return status == STATUS_REFRESHING;
	}

	public static boolean isLoadingMore(final int status) {
		return status == STATUS_LOADING_MORE;
	}

	public static boolean isReleaseToRefresh(final int status) {
		return status == STATUS_RELEASE_TO_REFRESH;
	}

	public static boolean isReleaseToLoadMore(final int status) {
		return status == STATUS_RELEASE_TO_LOAD_MORE;
	}

	public static boolean isSwipingToRefresh(final int status) {
		return status == STATUS_SWIPING_TO_REFRESH;
	}

	public static boolean isSwipingToLoadMore(final int status) {
		return status == STATUS_SWIPING_TO_LOAD_MORE;
	}

	public static boolean isRefreshStatus(final int status) {
		return status < STATUS_DEFAULT;
	}

	public static boolean isLoadMoreStatus(final int status) {
		return status > STATUS_DEFAULT;
	}

	public static boolean isStatusDefault(final int status) {
		return status == STATUS_DEFAULT;
	}

	public static String getStatus(int status) {
		final String statusInfo;
		switch (status) {
			case STATUS_REFRESHING:
				statusInfo = "status_refreshing";
				break;
			case STATUS_RELEASE_TO_REFRESH:
				statusInfo = "status_release_to_refresh";
				break;
			case STATUS_SWIPING_TO_REFRESH:
				statusInfo = "status_swiping_to_refresh";
				break;
			case STATUS_DEFAULT:
				statusInfo = "status_default";
				break;
			case STATUS_SWIPING_TO_LOAD_MORE:
				statusInfo = "status_swiping_to_load_more";
				break;
			case STATUS_RELEASE_TO_LOAD_MORE:
				statusInfo = "status_release_to_load_more";
				break;
			case STATUS_LOADING_MORE:
				statusInfo = "status_loading_more";
				break;
			case STATUS_LOAD_MORE_RETURNING:
				statusInfo = "status_load_more_returning";
				break;
			default:
				statusInfo = "status_illegal!";
				break;
		}
		return statusInfo;
	}

	public static void printStatus(int status) {
		Log.i(TAG, "printStatus:" + getStatus(status));
	}
}
